package uy.edu.um.ltic.server.communication;

import java.rmi.RemoteException;
import java.util.ArrayList;

import uy.edu.um.ltic.commons.GeneralEntitiesRemoteMgt;
import uy.edu.um.ltic.exception.DataBaseException;
import uy.edu.um.ltic.server.business.GeneralEntitiesFactory;

public class GeneralEntitiesRemoteServerMgr implements GeneralEntitiesRemoteMgt{

	private static GeneralEntitiesRemoteServerMgr instance = null;

	private GeneralEntitiesRemoteServerMgr() throws RemoteException{
				
	}

	public static GeneralEntitiesRemoteServerMgr getInstance()  throws RemoteException, DataBaseException{
		if (instance == null) {
			instance = new GeneralEntitiesRemoteServerMgr();
		}
		return instance;
	}
	
	@Override
	public void addCountry(String country) throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().addCountry(country);
	}

	@Override
	public void addPositionInCompany(String positionInCompany)
			throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().addPositionInCompany(positionInCompany);
		
	}

	@Override
	public void addBranch(String branch) throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().addBranch(branch);
		
	}

	@Override
	public void addDepartment(String department) throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().addDepartment(department);
	}

	@Override
	public void deleteCountry(String country) throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().deleteCountry(country);
	}

	@Override
	public void deletePositionInCompany(String positionInCompany)
			throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().deletePositionInCompany(positionInCompany);
	}

	@Override
	public void deleteBranch(String branch) throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().deleteBranch(branch);
	}

	@Override
	public void deleteDepartment(String department) throws RemoteException, DataBaseException {
		GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().deleteDepartment(department);
	}

	@Override
	public ArrayList<String> getCountries() throws RemoteException, DataBaseException {
		ArrayList<String> oListCountry =	GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().getCountries();
		return oListCountry;
	}

	@Override
	public ArrayList<String> getPositionsInCompany() throws RemoteException, DataBaseException {
		ArrayList<String> oListPositionsInCompany =	GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().getPositionsInCompany();
		return oListPositionsInCompany;
	}

	@Override
	public ArrayList<String> getBranches() throws RemoteException, DataBaseException {
		ArrayList<String> oListBranches =	GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().getBranches();
		return oListBranches;
	}

	@Override
	public ArrayList<String> getDepartments() throws RemoteException, DataBaseException {
		ArrayList<String> oListDepartments =	GeneralEntitiesFactory.getInstance().getGeneralEntitiesMgt().getDepartments();
		return oListDepartments;
	}

	@Override
	public void dropConnection(String nEmp) throws RemoteException {
		ServerSocket.dropConnection(nEmp);
	}

}
